type rec expr =
  | Cst(int)
  | Add(expr, expr)
  | Mul(expr, expr)
  | Var(int)
  | Let(expr, expr)

type env = list<int>

let rec eval = (expr: expr, env) => {
  switch expr {
  | Cst(i) => i
  | Add(a, b) => eval(a, env) + eval(b, env)
  | Mul(a, b) => eval(a, env) * eval(b, env)
  | Var(n) => env->List.getExn(n)
  | Let(e1, e2) => eval(e2, list{eval(e1, env), ...env})
  }
}
